<template>
  <view class="md-share-btn">
    <button open-type="share" class="share-btn" />
  </view>
</template>

<script setup lang="ts">
import {onShareAppMessage, onShareTimeline} from '@dcloudio/uni-app';
// const pages = getCurrentPages();
// console.log(pages);
const props = defineProps({
  title: String, // 分享标题
  path: String,
  imageUrl: String,
});

// 分享
onShareAppMessage(res => {
  console.log('md-share-btn::', res);
  return {
    title: props.title || 'isong music',
    imageUrl: props.imageUrl || 'https://cdn.xmxiaomai.com/isong_static/share.jpg',
    path: props.path || '/pages/index/index',
  };
});

</script>

<style scoped lang="scss">
.md-share-btn {
  position: relative;
  .share-btn {
    width: 40rpx;
    height: 40rpx;
    // 调整button默认样式
    border: none;
    border-radius: none;
    background-color: transparent;
    padding: 0;
    &::after {
      border: none;
      border-radius: none;
    }
    // 背景图
    background-image: url('https://cdn.xmxiaomai.com/isong_static/music/%E8%BD%AC%E5%8F%91.png');
    background-size: cover;
    background-repeat: no-repeat;
  }
}
</style>
